export const getTextByCode = (arr, code) => {
  let item = arr.find(v => v.code === code)
  return  item ? item.text : ''
}
export const getTextFactory = arr => {
  return code => getTextByCode(arr, code)
}
export const businessCreatedStatusDictionary =  [
  { code: -1, text: '已关闭' },
  { code: 0, text: '待审核' },
  { code: 1, text: '审核退回' },
  { code: 2, text: '待支付' },
  { code: 3, text: '交易异常' },
  { code: 4, text: '支付待确认' },
  { code: 5, text: '已支付，待划拨' },
  { code: 6, text: '已完成' },
  { code: 7, text: '交易异常' },
]
export const getTextByBusinessCreatedStatus = getTextFactory(businessCreatedStatusDictionary)

export const voiceLabelStatus = [
  { code: 0, text: '未标注' },
  { code: 1, text: '已标注' }
]
export const getTextByVoiceLabelStatus = getTextFactory(voiceLabelStatus)

export const orderTypeDictionary = [
  { text: '买入', code: 1 },
  { text: '获赠', code: 2 },
  { text: '卖出', code: 3 },
  { text: '赠出', code: 4 },
]
export const getTextByOrderType = getTextFactory(orderTypeDictionary)

export const priceStatusDictionary = [
  { text: '待审核', code: 0 },
  { text: '审核退回', code: 1 },
  { text: '审核通过', code: 2 },
]
export const getTextByPriceStatus = getTextFactory(priceStatusDictionary)

export const businessTypeDictionary = [
  { text: '云播客', code: 0 },
  { text: '译配', code: 1 },
]
export const getTextByBusinessType = getTextFactory(businessTypeDictionary)


export const businessTypeUnitDictionary = [
  { text: '字符', code: 0 },
  { text: '分钟', code: 1 },
]
export const getBusinessTypeUnit = getTextFactory(businessTypeUnitDictionary)

export const businessPriceTypeDictionary = [
  { text: '元/千字符', code: 0 },
  { text: '元/分钟', code: 1 },
]
export const getBusinessPriceType = getTextFactory(businessPriceTypeDictionary)
